<template>
  <div>
    <el-row :gutter="20">
      <el-col :span="8">
        <!-- 搜索 clearable:清空数据，@clear:查询数据-->
        <el-input v-model="xx" placeholder="输入学号进行查询，查询结果学生类型信息"
          ><template #append>
            <el-button @click="getls()"
              ><el-icon><Search /></el-icon
            ></el-button>
          </template> </el-input
      ></el-col>
       </el-row>
      <!--------------------------- 添加用户 -------------------------------->

    <el-table :data="user">
      <el-table-column type="index"></el-table-column>

      <el-tableColumn label="学号" prop="sid"></el-tableColumn>
      <el-tableColumn label="类型" prop="mal"></el-tableColumn>
      <el-tableColumn label="日期" prop="date"></el-tableColumn>

      <!-- <el-tableColumn label="操作" width="180px">
        <template v-slot="scope">
          <el-button round type="primary" size="mini" @click="editDialogVisible = true"
            ><el-icon><Edit /></el-icon
          ></el-button>
        </template>
      </el-tableColumn> -->
    </el-table>
  </div>
</template>

<script>
import { h } from 'vue'
import { ElNotification } from 'element-plus'
import { ref } from 'vue'
export default {
  data() {
    return {
      sid: ref(''),
      mal: ref(''),
      date: ref(''),

      addDialogVisible: false,
      editDialogVisible: false,
      deleteDialogVisible: false,
      user: [],
      xx: ref(''),
    }
  },
  created() {
    this.getls()
  },
  methods: {
    // 获取用户列表数据（getUserList）
    getls() {
      const that = this
      this.$axios.get('/gettype', { params: { xx: this.xx } }).then(function (response) {
        console.log(response)
        that.user.push(response['data'])
      })
    },
    del(row) {
      console.log(row)
      this.deleteDialogVisible = true
    },
    addDialogClosed() {
      this.$refs.addUserFormRef.resetFields()
    },
    editDialogClosed() {
      this.$refs.editUserFormRef.resetFields()
    },
    deleteDialogClosed() {
      this.$refs.editUserFormRef.resetFields()
    },
    insertstudent() {
      const that = this
      this.$axios
        .get('/insertstudent', {
          params: {
            sno: this.sno,
            name: this.name,
            password: this.password,
            level: this.level,
            gender: this.gender,
            age: this.age,
            dept: this.dept,
            class_sql: this.class_sql,
          },
        })
        .then(function (response) {
          that.addDialogVisible = false
          that.$message({
            message: h('i', { style: 'color: coral' }, '用户已插入数据库'),
          })
        })
    },
    // updatestudent() {
    //   const that = this
    //   this.$axios
    //     .get('/updatestudent', {
    //       params: {
    //         sno: this.updatesno,
    //         name: this.updatename,
    //         password: this.updatepassword,
    //         level: this.updatelevel,
    //         gender: this.updategender,
    //         age: this.updateage,
    //         dept: this.updatedept,
    //         class_sql: this.updateclass_sql,
    //       },
    //     })
    //     .then(function (response) {
    //       that.$message({
    //         message: '用户已更新',
    //       })
    //     })
    // },
    // deletestudent(e) {
    //   console.log(e)
    //   const that = this
    //   this.$axios
    //     .get('/deletestudent', {
    //       params: {
    //         sno: this.deletesno,
    //       },
    //     })
    //     .then(function (response) {
    //       that.$message({
    //         type: 'success',
    //         message: '用户已在数据库删除',
    //       })
    //     })
    // },
  },
}
</script>

<style lang="less" scoped></style>
